﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="StudentPresent.aspx.cs" Inherits="WebApplication1.StudentPresent" %>
<%@ Import Namespace="System.Data.SqlClient" %>
<script runat="server">

    void Button1_Click(Object sender, System.EventArgs e)
    {
        SqlCommand myCom;
        SqlDataReader myReader = null;    
        List<string> myStudent = GetMyStudentName();
        int i = 1;
        
        foreach (string temp in myStudent)
        {

            string query = "update OPEN_SUBJECT set present = '"
                + (GetChecked(i) ? "O" : "X")
                +"' where student_email = '"+temp+"'";//dkdldb@naver.com'";
            
            myCom = new SqlCommand(query, GetSqlConn());
            myReader = myCom.ExecuteReader();

            ++i;
        }

        if (myReader != null) myReader.Close();
        ShowMsgBox();       
    }

    public Boolean GetChecked(int index)
    {
        switch (index)
        {
            case 1:
                return CheckBox1.Checked;
            case 2:
                return CheckBox2.Checked;
            case 3:
                return CheckBox3.Checked;
            case 4:
                return CheckBox4.Checked;
            case 5:
                return CheckBox5.Checked;
        }
        return false;
    }

</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <asp:Label ID="Label1" runat="server" Text="Label" Visible="false"></asp:Label>
    <asp:CheckBox ID="CheckBox1" runat="server" Visible="false"/>
    <br></br>
        <asp:Label ID="Label2" runat="server" Text="Label" Visible="false"></asp:Label>
    <asp:CheckBox ID="CheckBox2" runat="server" Visible="false"/>
    <br></br>
        <asp:Label ID="Label3" runat="server" Text="Label" Visible="false"></asp:Label>
    <asp:CheckBox ID="CheckBox3" runat="server" Visible="false"/>
    <br></br>
        <asp:Label ID="Label4" runat="server" Text="Label" Visible="false"></asp:Label>
    <asp:CheckBox ID="CheckBox4" runat="server" Visible="false"/>
    <br></br>
        <asp:Label ID="Label5" runat="server" Text="Label" Visible="false"></asp:Label>
    <asp:CheckBox ID="CheckBox5" runat="server" Visible="false"/>
    <br></br>
    <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
      
    <div>
    
    </div>
    </form>
</body>
</html>
